
//
//  BaseTableViewController.swift
//  SwiftWeibo
//
//  Created by Lucky on 16/4/25.
//  Copyright © 2016年 Lucky. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorViewDelegate {
    
    var userLogin = UserAccount.userLogin()
    
    var visitorView: VisitorView?
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        userLogin ? super.loadView() : setupVisitorView()
        
        print(UserAccount.loadAccount()?.expires_Date)
    }
    
    private func setupVisitorView() {
        // 1,初始化未登录界面
        let customView = VisitorView()
        customView.delegate = self
        view = customView
        visitorView = customView
        
        // 2.设置导航条按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(BaseTableViewController.registerBtnClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(BaseTableViewController.loginBtnClick))
    }
    
    // MARK: - 登录界面代理回调
    func loginBtnClick() {
        print(#function)
        let oauthVC = OAuthViewController()
        
        let nav = UINavigationController(rootViewController: oauthVC)
        
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func registerBtnClick() {
        print(#function)
    }
}
